package com.pclong.doudizhu.server.demo1;
import java.util.*;

/**
 * Description:
 * </br>Copyright (C), 2005-2009, KK
 * </br>This program is protected by copyright laws.
 * </br>Program name: DouDiZhu
 * </br>Date: 12/10/09
 * @author kk
 * @version 1.0
 */

// store the abstract information of DDZCards
class DDZCardsInfo {
	private final int KINDS_OF_CARDS = 15;
	private final int MAX_VALUE = 17;
	private int[] numOfEachCard = new int[KINDS_OF_CARDS];
	
	public DDZCardsInfo() {}
	public DDZCardsInfo(DDZCards c)
	{
		for(int i=MAX_VALUE; i>2; i--)
			numOfEachCard[MAX_VALUE-i] = c.findCardByValue(i);
	}
	
	public int[] getNumOfEachCard()
	{
		return this.numOfEachCard;
	}
	
	public void update(int value, int diff)
	{
		if(this.numOfEachCard[MAX_VALUE-value]+diff > -1)
			this.numOfEachCard[MAX_VALUE-value] += diff;
	}
}

// TODO
// a plan for DDZCards to form the handCards
// two or more plans could be yielded from one DDZCards
class Plan {
	
	public Plan (DDZCards c)
	{
		
	}
	
}

// store the history information through the game, longer than Memory class
class History {
	
}

// should be initialized every time a new round start
class Memory {
	// played cards history
	private List<DDZHandCards> self;
	private List<DDZHandCards> previous;
	private List<DDZHandCards> after;
	private DDZCardsInfo left;
	
	public Memory()
	{
		this.self = new ArrayList<DDZHandCards>();
		this.previous = new ArrayList<DDZHandCards>();
		this.after = new ArrayList<DDZHandCards>();
		this.left = new DDZCardsInfo();
	}
	public Memory(DDZCards c)
	{
		this.self = new ArrayList<DDZHandCards>();
		this.previous = new ArrayList<DDZHandCards>();
		this.after = new ArrayList<DDZHandCards>();
		this.left = new DDZCardsInfo(c);
	}
	
	public void update(int pos, DDZHandCards playedCards)
	{
		if(pos == -1)
			this.previous.add(playedCards);
		else if(pos == 0)
			this.self.add(playedCards);
		else
			this.after.add(playedCards);
		
		// update the left cards info
		for(int i=0; i<playedCards.getDDZCards().getLength(); i++)
			this.left.update(playedCards.getDDZCards().getCardAt(i).value, -1);
	}
	
	public DDZCardsInfo getLeftCardsInfo()
	{
		return this.left;
	}
}

class Conclusion {
	
}

public class AI {

}